FROM scratch

LABEL maintainer="lijunyi@foton.com.cn"

ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en

ADD ubuntu-base-18.04.5-base-amd64.tar.gz /
COPY rootfs /

RUN apt-get update -y && apt-get upgrade -y && \
    apt-get install -y ca-certificates locales tzdata && sed -i 's#http:#https:#g' /etc/apt/sources.list && \
    apt-get clean && apt-get autoclean

RUN sed -i '/en_US\|zh_CN/s/# \+//' /etc/locale.gen && \
    locale-gen && update-locale LANG=en_US.UTF-8 LANGUAGE=en_US:en && \
    ln -sf /bin/bash /bin/sh && \
    echo "Asia/Shanghai" > /etc/timezone && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

RUN apt-get update -y && apt-get upgrade -y && \
    apt-get install -y adb bash-completion bc dc fastboot git gnupg htop lsof openssh-server sudo vim && \
    apt-get install -y autoconf automake build-essential cmake libtool libtool-bin pkgconf iproute2 iputils-ping pciutils && \
    apt-get install -y android-sdk-ext4-utils cpio device-tree-compiler e2fsprogs mkbootimg mtd-utils squashfs-tools u-boot-tools util-linux && \
    apt-get install -y bison curl wget flex fontconfig genext2fs gettext kmod lzop xsltproc zip unzip rar unrar python3-minimal python3-crypto && \
    apt-get install -y lib32z1-dev libc6-dev-i386 libgl1-mesa-dev libssl-dev libumockdev-dev libx11-dev libxml2-dev libxml2-utils x11proto-core-dev zlib1g-dev && \
    apt-get clean && apt-get autoclean

RUN mkdir -p /var/run/sshd /data /opt && chmod +x /usr/local/bin/entrypoint && \
    echo > /etc/motd && find /etc/update-motd.d/ -type f -iname '[1-9]*' | xargs rm -rf && \
    find /var/log -type f -iname '*.log' | xargs rm -rf && \
    find /usr/share/man/ /var/cache /var/lib/apt -type f | xargs rm -rf && touch /var/cache/apt/archives/lock

VOLUME ["/data", "/opt"]

EXPOSE 22
ENTRYPOINT ["/usr/local/bin/entrypoint"]
